<?php
use Spay\Spay;
use Spay\Order;
use Spay\Exception\SpayException;
use Spay\Notify;

error_reporting(E_ERROR);
//生成支付订单
define("BASE_PATH", dirname(__FILE__));
require BASE_PATH . DIRECTORY_SEPARATOR . './config.php';

require BASE_PATH . DIRECTORY_SEPARATOR . '../vendor/autoload.php';

Spay::$appId = APP_ID;// 设置 API Key
Spay::$appSecretKey = APP_SECRET_KEY;

//$data = 'deGykJHnPCwbYd6LWC81yO+H63Zd1riGaapJp8NpNTbCfU5ME3BSDobsq1+n67OuP4OMDUrFvmkLy7ymkHkQrcMBmc4hltOjDhE5CLeYZs7o/lEYjGX4nmfkfc5CNezVnx84Y25ZzfVyc7NjSgsErxraCpl3jKVFO4i11zSDooUDq18bhJusN1qILYRu3G9GKrv8M9KdvNxuYQ5IkuRcjqlQHnipM/Ni+QMRq5HlE+2TWbRCqxLWH6BAIW8eyWzW';
//$signTime = '1491980027';
//$sign = '9563D05AFB4C7A1B577173AD9F0A9046';

$data = $_REQUEST['data'];
$signTime = $_REQUEST['sign_time'];
$sign = $_REQUEST['sign'];

$string = Notify::parse($data, $sign, $signTime);
print_r($string);
$data = json_decode($string, true);
///支付成功
if ($data['trade_status'] == 1)
{
    //TODO check out_trade_no  amount is ok




    echo 'success';
}